package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2022-05-28
 * Time: 19:33
 */
public class FindOperation implements IOperation {
    @Override
    public void work(BookList books) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("查找图书！");
        String name = scanner.nextLine();
        int size = books.getSize();
        for (int i = 0; i < size; i++) {
            Book book = books.getBook(i);
            if(name.equals(book.getName())) {
                System.out.println("找到了这本书，信息如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书！");
    }
}
